# -*- coding: utf-8 -*-
from scrapy import cmdline
import sys,os
import logging

if __name__ == '__main__':
    '''
        运行指定爬虫，并传参
    '''
    city_code = sys.argv[1]
    company_code = sys.argv[2]
    task_id = sys.argv[3]
    task_date = sys.argv[4]
    spider_name = sys.argv[5]
    timer_param = sys.argv[6]
    timer_granularity = sys.argv[7]
    timer_id = sys.argv[8]
    miss_product_flag = 'FALSE'

    cmd = "scrapy crawl " + spider_name + " -a spider_name=" + spider_name + " -a city_code=" + city_code + " -a company_code=" + \
        company_code + " -a task_id=" + task_id + " -a task_date=" + task_date + " -a timer_param=" + timer_param + " -a timer_granularity=" + timer_granularity + " -a timer_id=" + timer_id + " -a miss_product_flag="+ miss_product_flag
    
    logging.info('cmd:%s' % cmd)
    cmdline.execute(cmd.split())
    # os.system(cmd)